package com.github.kezhenxu94.playground.java.network;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class JCrawler {
	
	public static void main(String[] args) {
		String url = "http://localhost:4000";
		try {
			URL doubanURL = new URL(url);
			URLConnection connection = doubanURL.openConnection();
			try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));) {
				for (String line = reader.readLine(); line != null; line = reader.readLine()) {
					System.out.println(line);
				}
			}
		} catch (Exception e) {
			System.err.println(url + " is not a valid URL");
		}
	}
}
